#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Author   : Moty
# @Time     : 2024/10/18 22:39
# @File     : kc16_35.py
# @Project  : CSPT
def parse_35_Remote_Stop_Command_Response(body):
    # 解析0x35 远程停机命令回复
    data = {
        "桩编号": f"{body[0:14]}({body[0:14]})",
        "枪号": f"{int(body[14:16], 16)}枪({body[14:16]})",
        "停止结果": f"{stop_result(body[16:18])}({body[16:18]})",
        "失败原因": f"{fail_result(body[18:20])}({body[18:20]})",
    }
    formatted_data = ""
    for key, value in data.items():
        formatted_data += f"{key}: {value}\n"
    return formatted_data


def stop_result(result):
    return "失败" if result == "00" else "成功" if result == "01" else "未知"


def fail_result(result):
    return "无" if result == "00" else "设备编号不匹配" if result == "01" else "枪未处于充电状态" if result == "02" \
        else "其他" if result == "03" else "未知"


__all__ = ['parse_35_Remote_Stop_Command_Response']
